/* GUI CONVERTED from rewarp2a.p (converter v1.75) Thu Oct  5 12:01:03 2000 */
/* rewarp2a.p - REPETITIVE                                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*F0PN*/ /*V8:ConvertMode=Report                                              */
/* REVISION: 7.3      LAST MODIFIED: 03/03/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 08/29/95   BY: STR *G0VD*                */
/* REVISION: 8.5      LAST MODIFIED: 04/04/96   BY: GWM *J0GG*                */
/* REVISION: 8.5      LAST MODIFIED: 03/06/97   BY: *J1K8* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 10/21/97   BY: ays *K13W*                */
/* REVISION: 8.6      LAST MODIFIED: 12/08/97   BY: *J27S* Julie Milligan     */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* REVISION: 9.1      LAST MODIFIED: 09/11/00   BY: *N0RQ* BalbeerS Rajput    */

/* WIP ADJUST VALUATION REPORT SUBPROGRAM - SORT BY SITE/ITEM/OP              */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

         {mfdeclre.i}
/*N0RQ*/ {gplabel.i}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rewarp2a_p_3 "Effective"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp2a_p_4 "Adjust Qty"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp2a_p_5 "Cost Set To Use"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp2a_p_6 "Cost Element"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp2a_p_7 "Cost"
/* MaxLen: Comment: */

&SCOPED-DEFINE rewarp2a_p_8 "Extended Cost"
/* MaxLen: Comment: */

/*N0RQ*
 * &SCOPED-DEFINE rewarp2a_p_1 "Total"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rewarp2a_p_2 "Site Total"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE rewarp2a_p_9 "Item Total"
 * /* MaxLen: Comment: */
 *N0RQ*/

/* ********** End Translatable Strings Definitions ********* */

/*K13W*/ {wbrp02.i}


         define shared variable dept like wc_dept.
         define shared variable dept1 like wc_dept label {t001.i}.
         define shared variable effdate as date label {&rewarp2a_p_3}.
         define shared variable effdate1 as date label {t001.i}.
         define shared variable emp like op_emp.
         define shared variable emp1 like op_emp label {t001.i}.
         define shared variable line like wo_line.
         define shared variable line1 like wo_line label {t001.i}.
         define shared variable lot like wo_lot.
         define shared variable lot1 like wo_lot label {t001.i}.
         define shared variable mch like wc_mch.
         define shared variable mch1 like wc_mch label {t001.i}.
         define shared variable part like wo_part.
         define shared variable part1 like wo_part label {t001.i}.
         define shared variable reason like op_rsn.
         define shared variable reason1 like op_rsn label {t001.i}.
         define shared variable shift like op_shift.
         define shared variable shift1 like op_shift label {t001.i}.
         define shared variable site like wo_site.
         define shared variable site1 like wo_site label {t001.i}.
         define shared variable wkctr like wc_wkctr.
         define shared variable wkctr1 like wc_wkctr label {t001.i}.
         define shared variable cost_set_to_use as character
                                                format "x" label {&rewarp2a_p_5}.
         define shared variable report_cost_elements like mfc_logical.

/*N04H*  {rewrsdef.i}                                                         */

         define variable qty_adjust like wr_qty_cumoadj
            column-label {&rewarp2a_p_4}.
         define variable cost_tot like glt_amt column-label {&rewarp2a_p_8}.
         define variable cost_element as character format "x(15)"
            label {&rewarp2a_p_6}.
         define variable cost_element_cost like iro_cost_tot
            column-label {&rewarp2a_p_7}.
         define variable total_qty as decimal.
         define variable routing as character.
         define variable bom_code as character.
         define variable cur_cost_mthd as character.
         define variable cur_cost_set as character.
         define variable gl_cost_mthd as character.
         define variable gl_cost_set as character.
         define variable ord_qty as decimal.
         define variable fieldname like _field._field-name.
/*J0GG*/ define variable tablename like _file._file-name.
         define variable fieldfound as log.
         define variable fieldlabel like _field._label.
         define variable fieldcollabel like _field._col-label.
         define variable fielddatatype like _field._data-type.
         define variable fieldformat like _field._format.
         define variable fielddesc like _field._desc.
         define variable fieldvalexp like _field._valexp.
         define variable fieldvalmsg like _field._valmsg.
         define variable fieldextent like _field._extent.

         {mfphead.i}

         FORM /*GUI*/ 
            skip
         with STREAM-IO /*GUI*/  frame skip1 page-top width 132.

         view frame skip1.

         for each op_hist no-lock
         where op_wo_lot >= lot and op_wo_lot <= lot1
         and op_part >= part and op_part <= part1
         and op_site >= site and op_site <= site1
         and op_line >= line and op_line <= line1
         and op_rsn >= reason and op_rsn <= reason1
         and op_wkctr >= wkctr and op_wkctr <= wkctr1
         and op_mch >= mch and op_mch <= mch1
         and op_dept >= dept and op_dept <= dept1
         and op_shift >= shift and op_shift <= shift1
         and op_emp >= emp and op_emp <= emp1
         and op_date >= effdate and op_date <= effdate1
         and op__dec02 <> 0
         use-index op_date,
         each wo_mstr no-lock
         where wo_lot = op_wo_lot
         and wo_nbr = "",
         each wr_route no-lock
         where wr_lot = op_wo_lot
         and wr_op = op_wo_op
/*J27S* * * BEGIN DELETE SECTION *
 *       ,
 *       each pt_mstr no-lock
 *       where pt_part = wo_part,
 *       each pl_mstr no-lock
 *       where pl_prod_line = pt_prod_line
 *J27S* * * END DELETE SECTION */
         break by op_site by op_part by op_wo_op by op_line by op_rsn
/*N0RQ*  with width 132 no-box: */
/*N0RQ*/ with frame f-a width 132 no-box:

            /* SET EXTERNAL LABELS */
/*N0RQ*/    setFrameLabels(frame f-a:handle).

            qty_adjust = op__dec02.
            accumulate qty_adjust(total by op_line).

            if last-of(op_line) then do:

/*J27S*/       find pt_mstr no-lock where pt_part = wo_part.
/*J27S*/       find pl_mstr no-lock where pl_prod_line = pt_prod_line.

               display
                  op_site
                  op_part
                  op_wo_op
                  op_line
                  accum sub-total by op_line qty_adjust @ qty_adjust WITH STREAM-IO /*GUI*/ .

               total_qty = accum sub-total by op_line qty_adjust.

/*N04H*        {rewrsget.i &lot=wr_lot &op=wr_op &lock=no-lock}          */

               /*GET COST SET TO USE*/
               {rescrp2a.i}

/*G0VD*/       if available iro_det then
                  cost_tot = total_qty * iro_cost_tot.
/*G0VD*/       else
                  cost_tot = 0.

               accumulate cost_tot(total by op_site by op_part by op_wo_op).

/*G0VD*/       if available iro_det then do:
/*J1K8*/          tablename = "iro_det".
                  if report_cost_elements then do:
                     {reworp3a.i iro_mtl_ll "down 1."}
                     {reworp3a.i iro_lbr_ll "down 1."}
                     {reworp3a.i iro_bdn_ll "down 1."}
                     {reworp3a.i iro_sub_ll "down 1."}
                     {reworp3a.i iro_mtl_tl "down 1."}
                     {reworp3a.i iro_lbr_tl "down 1."}
                     {reworp3a.i iro_bdn_tl "down 1."}
                     {reworp3a.i iro_sub_tl "down 1."}
                     {reworp3a.i iro_cost_tot "down 1."}
                  end.
                  else do:
                     {reworp3a.i iro_cost_tot}
                  end.
/*G0VD*/       end.
/*G0VD*/       else do:
/*G0VD*/          if report_cost_elements then do:
/*G0VD*/             {reworp3c.i "down 1."}
/*G0VD*/          end.
/*G0VD*/          else do:
/*G0VD*/             {reworp3c.i}
/*G0VD*/          end.
/*G0VD*/       end.

               if last-of(op_part) then do:

                  underline cost_tot.

                  display
/*N0RQ*             {&rewarp2a_p_9} @ cost_element_cost*/
/*N0RQ*/            getTermLabel("ITEM_TOTAL",15) @ cost_element_cost
                    accum sub-total by op_part cost_tot @ cost_tot WITH STREAM-IO /*GUI*/ .

                  down 1.

               end.

               if last-of(op_site) then do:

                  underline cost_tot.

                  display
/*N0RQ*              {&rewarp2a_p_2} @ cost_element_cost*/
/*N0RQ*/             getTermLabel("SITE_TOTAL",15) @ cost_element_cost
                     accum sub-total by op_site cost_tot @ cost_tot WITH STREAM-IO /*GUI*/ .

                  down 1.

               end.

               if last(op_site) then do:

                  underline cost_tot.

                  display
/*N0RQ*             {&rewarp2a_p_1} @ cost_element_cost*/
/*N0RQ*/            getTermLabel("TOTAL",15) @ cost_element_cost
                    accum total cost_tot @ cost_tot WITH STREAM-IO /*GUI*/ .

                  down 1.

               end.

            end.

            
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


         end.

/*K13W*/ {wbrp04.i}
